using FileServer.Abstractions.Models;
using FileServer.Abstractions.Models.Result;
using Gateway.IApplication.UploadFiles.Output;

namespace FileServer.Abstractions;

/// <summary>
/// 文件操作
/// </summary>
public interface IFileOperator
{
    /// <summary>
    /// 上传文件-stream
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    Task<UploadResult> UploadAsync(UploadFileInputStream input);

    /// <summary>
    /// 上传文件-form file
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    Task<UploadResult> UploadAsync(UploadFileInputForm input);

    /// <summary>
    /// 上传文件-remote
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    Task<UploadResult> UploadAsync(UploadFileInputRemote input);

    /// <summary>
    /// 根据文件路径删除文件
    /// </summary>
    /// <param name="fileUrl"></param>
    /// <returns></returns>
    Task<bool> Delete(string fileUrl);

    /// <summary>
    /// 根据文件id删除文件
    /// </summary>
    /// <param name="fileUrl"></param>
    /// <returns></returns>
    Task<bool> DeleteById(string id);

    /// <summary>
    /// 将临时文件转为正式文件
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    Task<bool> SaveTemp(string path);

    /// <summary>
    /// 将临时文件转为正式文件
    /// </summary>
    /// <param name="paths"></param>
    /// <returns></returns>
    Task<bool> SaveTemp(List<string> paths);

    /// <summary>
    /// 分片上传
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="fileName"></param>
    /// <param name="uploadId"></param>
    /// <param name="partSize"></param>
    /// <param name="partNumber"></param>
    /// <returns></returns>
    Task<MultipartUploadResult> PartUploadAsync(UploadPartInputStream stream);

    /// <summary>
    /// 完成分片上传-合并
    /// </summary>
    /// <param name="path"></param>
    /// <param name="uploadId"></param>
    /// <returns></returns>
    Task<string> FinishMultipartUploadAsync(UploadPartFinishRequest request, Action<FinishUploadResult> callback = null);
}